﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Entitas;

public class HUD : MonoBehaviour, IStatisticsListener
{
	
	[SerializeField]
	private Button rankingBtn;

	[SerializeField]
	private Text scoreText;

	// Use this for initialization
	void Start () 
	{
        Entity player = Contexts.sharedInstance.core.GetEntityWithPlayerId("Player1");
		player.AddStatisticsListener(this);
		rankingBtn.onClick.AddListener(OnRankingClick);
	}

    private void OnRankingClick()
    {
		Debug.Log("rankingBtn onClick");
		Contexts.sharedInstance.core.CreateEntity()
			.AddParent(transform.root)
	        .AddAsset(Res.RankingListView);		
    }

    void IStatisticsListener.StatisticsChanged(StatisticsComponent statistics)
    {
		scoreText.text = statistics.score.ToString();
    }
}
